package com.breeze.register;

import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.breeze.common.login.LoginDrawable;
import com.breeze.common.login.net.LoginAddress;
import com.breeze.common.login.net.LoginBean;

import java.io.IOException;

import brouter.annotation.BRouter;
import brouter.annotation.Parameter;
import brouter.api.ParameterManager;

@BRouter(path = "/register/RegisterActivity")
public class RegisterActivity extends AppCompatActivity {
    private static final String TAG = "RegisterActivity";
    @Parameter
    String name;
    @Parameter(name = "pwd")
    String password;
    @Parameter(name = "/login/Drawable")
    LoginDrawable loginDrawable; // 公共基础库common

    @Parameter(name = "/login/getLoginBean")
    LoginAddress loginAddress;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        ParameterManager.bind(this);
        ImageView imageView = findViewById(R.id.image);
        imageView.setImageResource(loginDrawable.getLoginRes());
        Toast.makeText(this, "name:" + name + ", password:" + password, Toast.LENGTH_SHORT).show();
        new Thread() {
            @Override
            public void run() {
                super.run();
                try {
                    LoginBean loginBean = loginAddress.getLoginBean("aa205eeb45aa76c6afe3c52151b52160", "144.34.161.97");
                    Log.i(TAG, "从Register组件跨组件到Login组件，并使用Login组件的网络请求功能：" + loginBean.toString());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }.start();
    }
}
